<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{$title}</title>
<link rel="stylesheet" href="Res/boot/css/bootstrap.min.css" type="text/css" media="screen" />
<script type="text/javascript" src="Res/js/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="Res/js/jquery.cookie.js"></script>
<link rel="stylesheet" href="Res/css/global.css" type="text/css" />

</head>

<body>
<span class="cp_title">{$title}</span>
<div class="table_con form-horizontal" style="margin: 0 auto;text-align: center;">
    <div class="form-group">
        <label class="col-sm-2 control-label">URL：</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="url" id="url" />
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-2"></div>
        <div class="col-sm-5">
            <button type="button" id="btn-search" class="btn btn-primary btn-lg btn-block">查询</button>   
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-2"></div>
        <div class="col-sm-5">
            <button type="button" id="btn_fx_title" class="btn btn-primary btn-lg">分析标题</button>   
            <button type="button" id="btn_fx_first" class="btn btn-primary btn-lg">分析首楼</button>
            <button type="button" id="btn_fx_nfloor" class="btn btn-primary btn-lg">分析1楼~N楼(限楼主)</button>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">楼主信息：</label>        
        <div class="col-sm-3">
            名称:<label id="author_name"></label>
        </div>
        <div class="col-sm-2">
            ID:<label id="author_id"></label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">标题：</label>
        <div class="col-sm-5">
            <input type="text" id="title" class="form-control" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">首楼：</label>
        <div class="col-sm-5">
            <textarea rows="3" class="form-control" id="first"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">N楼：</label>
        <div class="col-sm-5">
            <textarea rows="10" class="form-control" id="nfloor"></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">HTML内容：</label>
        <div class="col-sm-5">
            <!--<div class="panel-success" id="content" style="height: 100px;"></div>-->
            <textarea rows="10" class="form-control" id="content"></textarea>
        </div>
    </div>
</div>
{literal}
<script>    
$(function(){
    var cookie_url = $.cookie("url");
    if(typeof cookie_url !== 'undefined') {
        $("#url").val(cookie_url);
    }
    var _data = null;
    $("#btn_fx_title").click(function(){        
        get_title();    
    });
    $("#btn_fx_first").click(function(){
        get_first_floor();
    });
    $("#btn_fx_nfloor").click(function(){
        get_n_floor();
    });
    $("#btn-search").click(function(){
        var url = $("#url").val();        
        if(url==='') {
            $("#url").focus();return;
        }
        $.cookie("url", url);
        var gourl = 'index.php?c=story&m=doget';
        var param = new Object();
        param.url = url;
        $.post(gourl, param, function(data){
            if(data.status === 0) {
                $("#content").val(data.msg);
                var data = $("#content").val();
                _data = $(data);
                if(typeof _data !== 'undefined') {
                    get_author_info();
                    get_title();
                    get_first_floor();
                }
            } else {
                alert(data.msg);
            }
        }, 'json');
    });
    function get_author_info(){
        var info = _data.find("div[class*='atl-menu']").find("div[class='atl-info']").find("a");
        var author_id = info.attr("uid");
        var author_name = info.attr("uname");
        $("#author_name").html(author_name);
        $("#author_id").html(author_id);
    }
    function get_title(){
        var title = _data.find("div[id^='post_head']").find("span[class='s_title']").find("span").html();        
        $("#title").val(title);
    }
    function get_first_floor(){
        var first = _data.find("div[class='atl-item host-item']").find("div[class^='bbs-content']").html();
        $("#first").html(first);
    }
    function get_n_floor(){
        var nfloor = _data.find("div[class^='atl-main']").find("div[class='atl-item']");
        $.each(nfloor, function(k, data){
            var _this = $(data);
            var content = _this.find("div[class='bbs-content']").html();
            var author_info = _this.find("div[class='atl-head']").find("div[class='atl-info']");
            var aid = author_info.find('a').attr("uid");
            var uname = author_info.find('a').html();          
            var time = author_info.find("span:last").html();            
            var _aid = $("#author_id").html();
            if(aid == _aid) {
                console.log(time + ','+aid + '->' + uname);
               console.log(content);
            }            
        });
    }
});
</script>
{/literal}
</script>
</body>
</html>

